<?php include './admin/view/header.inc.htm'; ?>

<div class="panel">
	<div class="header">编辑文章</div>
	<div class="body">
		<form method="POST" id="form" action="admin/article-update-<?php echo $articleid; ?>.htm">
			<table class="form">
				<tr>
					<th><span class="red">*</span> 文章分类：</th>
					<td>
						<select name="cateid" id="cateid">
						<?php foreach($conf['cate'] as $_cateid=>$catename) { ?>
							<option value="<?php echo $_cateid; ?>" <?php if($article['cateid'] == $_cateid){ echo 'selected';  } ?>>><?php echo $catename; ?></option>
						<?php } ?>
						</select>
					</td>
				</tr>
				<tr>
					<th><span class="red">*</span> 标题：</th>
					<td><input type="text" name="subject" id="subject" value="<?php echo $article['subject']; ?>" /></td>
				</tr>
				<tr>
					<th><span class="red">*</span> 内容：</th>
					<td><textarea name="message" id="message" rows="8" style="width: 800px; height:300px"><?php echo $article['message']; ?></textarea></td>
				</tr>
				<tr>
					<th>简介：</th>
					<td><textarea name="brief" rows="3" style="height:auto"><?php echo $article['brief']; ?></textarea></td>
				</tr>
				<tr>
					<th>SEO 标题：</th>
					<td><input type="text" name="seo_title" value="<?php echo $article['seo_title']; ?>" /></td>
				</tr>
				<tr>
					<th>SEO 关键词：</th>
					<td><input type="text" name="seo_keywords" value="<?php echo $article['seo_keywords']; ?>" /></td>
				</tr>
				<tr>
					<th>SEO 描述：</th>
					<td><input type="text" name="seo_description" value="<?php echo $article['seo_description']; ?>" /></td>
				</tr>
				<tr>
					<th>&nbsp;</th>
					<td>
						<button type="submit" id="submit" loading-text="正在提交..." class="blue big">确定</button>
						<a href="admin/article-read-<?php echo $article['articleid']; ?>.htm" target="_blank">查看文章</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>

<?php include './admin/view/footer.inc.htm'; ?>

<link rel="stylesheet" type="text/css" href="xneditor/editor.css" />
<script src="xneditor/editor.js"></script>
<script>
var editor = new $.XNEditor({textarea: 'message', image_upload_url:'admin/article-upload.htm', image_upload_width: <?php echo $conf['upload_image_width']; ?>, file_upload_url:'admin/article-upload.htm'});
var jsubject = $("#subject");
var jcateid = $("#cateid");
var jform = $("#form");
var jsubmit = $("#submit");
var jmessage = $('#message');

jform.on('submit', function(){
	var postdata = jform.serialize();
	jsubmit.button('loading');
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			jsubmit.text(message);
			setTimeout(function(){
				jsubmit.button('reset');
			}, 1000);
			return;
		} else if(code == 1) {
			jcateid.popover(message).focus();
		} else if(code == 2) {
			jsubject.popover(message).focus();
		} else if(code == 3) {
			editor.jeditor.popover(message).focus();
		} else {
			$.alert(message);
		}
		jsubmit.button('reset');
	});
	return false;
});
</script>